//mui.os.plus;//是否是5+环境(app)
//mui.os.ios;//是否是ios系统
//mui.os.iphone;//是否是iphone
//mui.os.ipad;//是否是ipad
//mui.os.android;//是否是android系统 http://121.41.91.126/
var appConfig={
	shiciServiceHost:'http://121.41.91.126:8099',
	/// shiciServiceHost:'http://121.41.91.126:8099', http://www.shiwenweb.cn:8099
	shiciLocalServiceHost:'http://192.168.100.104:8099',
	shiciTestServiceHost:'http://121.41.91.126:8099',
}

function getShiciServiceHost(){
	var envVal=SettingInfoManager.getEnv();
	if(envVal){
		if(envVal=='local'){
			appConfig.shiciServiceHost=appConfig.shiciLocalServiceHost;
		}else if(envVal=='test'){
			appConfig.shiciServiceHost=appConfig.shiciTestServiceHost;
		}
	}
	return appConfig.shiciServiceHost;
}

function getRequestVersion(){
	return 3;
}

/******************************************************/
SettingInfoManager=function(){
	
}

SettingInfoManager.settingName={
	env:'env',
	font:'_system',
	enabledHistory:'enabledHistory',
	historyShiwen:'historyShiwen',
	historySentence:'historySentence',
	historyWriter:'historyWriter',
	likeShiwen:'likeShiwen',
	likeSentence:'likeSentence',
	likeWriter:'likeWriter'
}

SettingInfoManager.settingInfo={
	env:'test',
	enabledHistory:'true',
	historyShiwen:[],
	historySentence:[],
	historyWriter:[],
	likeShiwen:[],
	likeSentence:[],
	likeWriter:[],
}

SettingInfoManager.getSettingInfo=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	//
	var envName=SettingInfoManager.settingName.env;
	var envVal=storageManager.getItem(envName);
	SettingInfoManager.settingInfo[envName]=envVal||SettingInfoManager.settingInfo[envName];
	//
	var enabledHistoryName=SettingInfoManager.settingName.enabledHistory;
	var enabledHistory=storageManager.getItem(enabledHistoryName);
	SettingInfoManager.settingInfo[enabledHistoryName]=enabledHistory||SettingInfoManager.settingInfo[enabledHistoryName];
	//浏览历史
	var historyShiwenName=SettingInfoManager.settingName.historyShiwen;
	var historyShiwen=storageManager.getItem(historyShiwenName);
	if(historyShiwen){
		SettingInfoManager.settingInfo[historyShiwenName]=historyShiwen.split(",");
	}
	//
	var historySentenceName=SettingInfoManager.settingName.historySentence;
	var historySentence=storageManager.getItem(historySentenceName);
	if(historySentence){
		SettingInfoManager.settingInfo[historySentenceName]=historySentence.split(",");
	}
	//
	var historyWriterName=SettingInfoManager.settingName.historyWriter;
	var historyWriter=storageManager.getItem(historyWriterName);
	if(historyWriter){
		SettingInfoManager.settingInfo[historyWriterName]=historyWriter.split(",");
	}
	//我的收藏
	var likeShiwenName=SettingInfoManager.settingName.likeShiwen;
	var likeShiwen=storageManager.getItem(likeShiwenName);
	if(likeShiwen){
		SettingInfoManager.settingInfo[likeShiwenName]=historyShiwen.split(",");
	}
	//
	var likeSentenceName=SettingInfoManager.settingName.likeSentence;
	var likeSentence=storageManager.getItem(likeSentenceName);
	if(likeSentence){
		SettingInfoManager.settingInfo[likeSentenceName]=likeSentence.split(",");
	}
	//
	var likeWriterName=SettingInfoManager.settingName.likeWriter;
	var likeWriter=storageManager.getItem(likeWriterName);
	if(likeWriter){
		SettingInfoManager.settingInfo[likeWriterName]=likeWriter.split(",");
	}
	//
	return settingInfo;
}

SettingInfoManager.getEnv=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var envVal=storageManager.getItem('env');
	return envVal;
}

SettingInfoManager.setEnv=function(env){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	storageManager.setItem('env',env);
}

SettingInfoManager.getFont=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var fontVal=storageManager.getItem('font');
	return fontVal;
}

SettingInfoManager.setFont=function(font){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	storageManager.setItem('font',font);
	SettingInfoManager.setPageFontFromSetting();
}

SettingInfoManager.getDetPagePeituShowTypeSetting=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var setVal=storageManager.getItem('detPagePeituShowType');
	return setVal;
}

SettingInfoManager.setDetPagePeituShowTypeSetting=function(peituShowType){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	storageManager.setItem('detPagePeituShowType',peituShowType);
}

SettingInfoManager.getWriterDetPageCoverTypeSetting=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var setVal=storageManager.getItem('writerDetPageCoverType');
	return setVal;
}

SettingInfoManager.setWriterDetPageCoverTypeSetting=function(coverType){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	storageManager.setItem('writerDetPageCoverType',coverType);
}

SettingInfoManager.setPageFontFromSetting=function(){
	var fontVal=SettingInfoManager.getFont();
	//console.log("set fontVal="+fontVal);
	if(fontVal){
		$('body').css('font-family',fontVal);
	}else{
		$('body').css('font-family','');
	}
}

SettingInfoManager.getPrivilageConfirmResult=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var confirmResultVal=storageManager.getItem('privilageConfirmResult');
	return confirmResultVal;
}

SettingInfoManager.setPrivilageConfirmResult=function(confirmResult){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	storageManager.setItem('privilageConfirmResult',confirmResult);
}

SettingInfoManager.timers={};

SettingInfoManager.timeCheckAndSetPageFontFromSetting=function(timerName){
	SettingInfoManager.setPageFontFromSetting();
	var timer= SettingInfoManager.timers[timerName];
	if(timer){
		clearInterval(timer);
		timer=null;
		SettingInfoManager.timers[timerName]=null;
	}
	timer = setInterval(function(){
		SettingInfoManager.setPageFontFromSetting();
	},2000);//启动计时器，调用字体设置函数，
	SettingInfoManager.timers[timerName]=timer;
}


SettingInfoManager.setEnabledHistory=function(enable){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var enabledHistoryName=SettingInfoManager.settingName.enabledHistory;
	if(enable){
		storageManager.setItem(enabledHistoryName,'true');
	}else{
		storageManager.setItem(enabledHistoryName,'false');
		SettingInfoManager.removeItem(SettingInfoManager.settingName.historyShiwen);
		SettingInfoManager.removeItem(SettingInfoManager.settingName.historySentence);
		SettingInfoManager.removeItem(SettingInfoManager.settingName.historyWriter);
	}
}

SettingInfoManager.getEnabledHistory=function(){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var enabledHistoryName=SettingInfoManager.settingName.enabledHistory;
	var enabled=storageManager.getItem(enabledHistoryName);
	if('true'==enabled){
		return true;
	}
	if('false'==enabled){
		return false;
	}
	return 'true'==SettingInfoManager.settingInfo[enabledHistoryName];
}

SettingInfoManager.addHistoryInfo=function(historyName,objId){
	if(SettingInfoManager.getEnabledHistory()){
		SettingInfoManager.addToList(historyName,objId,true);
	}
}

SettingInfoManager.getHistoryInfo=function(historyName){
	return SettingInfoManager.getList(historyName);
}

SettingInfoManager.removeItem=function(itemName){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	storageManager.removeItem(itemName);　　
}

SettingInfoManager.removeFromList=function(listName,objId){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var list=SettingInfoManager.getList(listName);　
	if(list && list.length>0){
		var listStr='';
		var removeCount=0;
		mui.each(list,function(index,value){
			if(value && value!=objId){
				listStr+=(value+",");
			}else{
				removeCount++;
			}
		});
		storageManager.setItem(listName,listStr);
		return removeCount;
	}
	return 0;
}

SettingInfoManager.addToList=function(listName,objId,repeatAble){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	console.info('addToList:'+listName+'='+objId);
	var listStr=storageManager.getItem(listName);
	listStr=listStr||'';
	var list=listStr.split(",");
	if(!repeatAble && $.inArray(objId+'',list)>=0){
		return 0;
	}
	list.unshift(objId);
	var recordHasJoninId={};
	listStr='';
	mui.each(list,function(index,value){
		if(value && !recordHasJoninId[value] && index<50){
			listStr+=(value+",");
			recordHasJoninId[value]='1';
		}
	});
	//
	storageManager.setItem(listName,listStr);
	console.info('addToList:'+listName+'='+objId+';add 1');
	return 1;
}

SettingInfoManager.getList=function(listName){
	var storageManager=('undefined'==typeof(plus))?localStorage:plus.storage;
	var listStr=storageManager.getItem(listName);
	if(!listStr){
		return [];
	}
	var retArray=[];
	var array = listStr.split(',');
	mui.each(array,function(index,value){
		if(value){
			retArray.push(value);
		}
	});
	return retArray;
}

SettingInfoManager.loaclToPlusStorage=function(){
	if(!plus.storage.getItem("plusStorage")){
		//console.log("loaclToPlusStorage");
		//
		var enabledHistoryName=SettingInfoManager.settingName.enabledHistory;
		var enabledHistory=localStorage.getItem(enabledHistoryName);
		enabledHistory=enabledHistory||SettingInfoManager.settingInfo[enabledHistoryName];
		plus.storage.setItem(enabledHistoryName,enabledHistory);
		//
		var historyShiwenName=SettingInfoManager.settingName.historyShiwen;
		var historyShiwen=localStorage.getItem(historyShiwenName);
		if(historyShiwen){
			//console.log("historyShiwen="+historyShiwen);
			plus.storage.setItem(historyShiwenName,historyShiwen);
		}
		//
		var historySentenceName=SettingInfoManager.settingName.historySentence;
		var historySentence=localStorage.getItem(historySentenceName);
		if(historySentence){
			//console.log("historySentence="+historySentence);
			plus.storage.setItem(historySentenceName,historySentence);		
		}
		//
		var likeShiwenName=SettingInfoManager.settingName.likeShiwen;
		var likeShiwen=localStorage.getItem(likeShiwenName);
		if(likeShiwen){
			//console.log("likeShiwen="+likeShiwen);
			plus.storage.setItem(likeShiwenName,likeShiwen);
		}
		//
		var likeSentenceName=SettingInfoManager.settingName.likeSentence;
		var likeSentence=localStorage.getItem(likeSentenceName);
		if(likeSentence){
			//console.log("likeSentence="+likeSentence);
			plus.storage.setItem(likeSentenceName,likeSentence);
		}
		plus.storage.setItem("plusStorage","true");
	}
}

/******************************************************/
RefreshAbleScroll=function(eleSel,opts){
	this.eleSel=eleSel;
	this.options=$.extend(true,{},RefreshAbleScroll.defConfig,opts);
	this.scroll=mui(eleSel).scroll();
	//
	this.inited=false;
	this.loading=false;
	this.canUpLoadMore=true;
	this.canDownLoadMore=true;
	//
	this.needDoDownloadFun=false;
	//
	this.init();
}

RefreshAbleScroll.defConfig={
	up:{
		enabled:true,
		initLoadOnce:true,
		hiddenNoMoreText:false,
		detHeight:0,
		detDelayTime:0,
		loadFunction:function(){},
		moreText:'上拉加载更多',
		loadingText:'加载中...',
		noMoreText:'没有更多数据了',
		textEleClass:'xq-scroll-up-text'
	},
	down:{
		enabled:false,
		//initLoadOnce:false,
		detHeight:0,
		detDelayTime:0,
		loadFunction:function(that){that.loading=false},
		moreText:'松开后刷新',
		loadingText:'加载中...',
		noMoreText:'没有更多数据了',
		textEleClass:'xq-scroll-down-text'
	}
}

RefreshAbleScroll.prototype.init=function(){
	if(this.inited){
		return;
	}
	var that=this;
	//
	$(this.eleSel).on('scroll',function(e){
		if(that.options.scrollCallBack){
			that.options.scrollCallBack(that,e);
		}
		if(that.loading){
			return;
		}
		if(that.canUpLoadMore && that.options.up.enabled){
			that.tryDoUpLoad();
		}
		if(that.canDownLoadMore && that.options.down.enabled){
			that.tryDoDownLoad();
		}
	});
	if(this.options.up.enabled){
		var textEle='<div class="'+this.options.up.textEleClass+'">'+this.options.up.moreText+'</div>';
		$(this.eleSel).find('.mui-scroll').append(textEle);
		//
		if(this.options.up.initLoadOnce){
			that._doUpLoadFunction();
		}
	}
	if(this.options.down.enabled){
		var textEle='<div class="'+this.options.down.textEleClass+' xq-hidden">'+this.options.down.moreText+'</div>';
		$(this.eleSel).find('.mui-scroll').before(textEle);
	}
	this.inited=true;
}

RefreshAbleScroll.prototype.tryDoUpLoad=function(){
	var that=this;
	$(that.eleSel).find('.mui-scroll .'+that.options.up.textEleClass).removeClass('xq-hidden');
	var scrollTop = that.scroll.y;
	var maxY = that.scroll.maxScrollY;
	var detHeight=that.options.up.detHeight;
	var nowTime=new Date().getTime();
	if(scrollTop<maxY){
		that.upDelayStartTime = !that.upDelayStartTime ? nowTime:that.upDelayStartTime;
	}else{
		that.upDelayStartTime = null;
	}
	if(detHeight>0){
		//当延迟一段时间后滚动位置才到达指定高度才刷新--主要是区分快速滚动和认为上拉
		if(that.options.up.detDelayTime>0){
			//只响应人为上拉
			if(that.upDelayStartTime && (nowTime-that.upDelayStartTime)>=that.options.up.detDelayTime
					&& scrollTop<=(maxY-detHeight)){
				that.upDelayStartTime=null;
				that._doUpLoadFunction();
			}
		}else{
			//响应快速滚动和人为上拉
			if(scrollTop<=(maxY-detHeight)){
				that._doUpLoadFunction();
			}
		}
	}else {
		if(scrollTop==maxY){
			that._doUpLoadFunction();
		}
	}
}

RefreshAbleScroll.prototype.tryDoDownLoad=function(){
	var that=this;
	$(that.eleSel).find('.mui-scroll .'+that.options.up.textEleClass).removeClass('xq-hidden');
	var scrollTop = that.scroll.y;
	var detHeight=that.options.down.detHeight;
	var nowTime=new Date().getTime();
	if(scrollTop>0){
		that.downDelayStartTime = !that.downDelayStartTime ? nowTime:that.downDelayStartTime;
	}else{
		that.downDelayStartTime = null;
		if(that.needDoDownloadFun){
			that._doDownLoadFunction();
		}
		that.needDoDownloadFun=false;
		$("."+that.options.down.textEleClass).addClass("xq-hidden");
	}
	if(detHeight>0){
		//当延迟一段时间后滚动位置才到达指定高度才刷新--主要是区分快速滚动和认为上拉
		if(that.options.down.detDelayTime>0){
			//只响应人为上拉
			if(that.downDelayStartTime && (nowTime-that.downDelayStartTime)>=that.options.down.detDelayTime
					&& scrollTop>=detHeight){
				that.downDelayStartTime=null;
				that.needDoDownloadFun=true;
				$("."+that.options.down.textEleClass).removeClass("xq-hidden");
			}
		}else{
			//响应快速滚动和人为上拉
			if(scrollTop>=detHeight){
				this.needDoDownloadFun=true;
			}
		}
	}
}
/**
 * @param {Object} opt{enabled:true|false,textShowStatus:'show'|'hidden'}
 */
RefreshAbleScroll.prototype.resetUpEnabled=function(opt){
	this.options.up.enabled=false;
	if(opt.enabled){
		this.options.up.enabled=true;
	}
	if(opt.textShowStatus=='show'){
		$(this.eleSel).find('.mui-scroll .'+this.options.up.textEleClass).removeClass('xq-hidden');
	}else{
		$(this.eleSel).find('.mui-scroll .'+this.options.up.textEleClass).addClass('xq-hidden');
	}
}

RefreshAbleScroll.prototype.loadOver=function(canUpLoadMore){
	var that=this;
	that.delayStartTime=null;
	setTimeout(function(){
		that.loading=false;
		that.canUpLoadMore=canUpLoadMore;
		//
		var newText=that.options.up.moreText;
		if(!that.canUpLoadMore){
			newText=that.options.up.noMoreText;
			if(that.options.up.hiddenNoMoreText){
				$(that.eleSel).find('.mui-scroll .'+that.options.up.textEleClass).addClass('xq-hidden');
			}
		}
		$(that.eleSel).find('.mui-scroll .'+that.options.up.textEleClass).html(newText);
	},500);
	
}

RefreshAbleScroll.prototype.reInit=function(){
	this.loading=false;
	this.canUpLoadMore=true;
	var newText=this.options.up.moreText;
	$(this.eleSel).find('.mui-scroll .'+this.options.up.textEleClass).html(newText);
	//
	this.scroll.scrollTo(0,0,10);
	this.scroll.refresh();
	//
	if(this.options.up.initLoadOnce){
		this._doUpLoadFunction();
	}
}

RefreshAbleScroll.prototype._doUpLoadFunction=function(){
	var that=this;
	that.loading=true;
	var newText=that.options.up.loadingText;
	$(that.eleSel).find('.mui-scroll .'+that.options.up.textEleClass).html(newText);
	that.options.up.loadFunction(that);
}

RefreshAbleScroll.prototype._doDownLoadFunction=function(){
	var that=this;
	that.loading=true;
	var newText=that.options.down.loadingText;
	$(that.eleSel).find('.mui-scroll .'+that.options.down.textEleClass).html(newText);
	that.options.down.loadFunction(that);
}

/********************************************************************/
commonUtils=function(){
	
}
//显示加载框
commonUtils.showLoading = function(message,opts) {
	var html = '';
	html += '<i class="mui-spinner mui-spinner-white"></i>';
	html += '<p class="text">' + (message || "数据加载中") + '</p>';
	
	//遮罩层
	var $mask=$(".mui-show-loading-mask");
	if($mask.lenght==0){
		$mask = $('<div></div>');
		$mask.addClass("mui-show-loading-mask");
		if(opts && opts.maskBgColor){
			$mask.css('background-color',opts.maskBgColor);
		}
		$('body').append($mask);
		$mask.on("touchmove", function(e){e.stopPropagation();e.preventDefault();});
	}else{
		$mask.removeClass("mui-show-loading-mask-hidden");
	}
	//加载框
	var $toast=$(".mui-show-loading");
	if($toast.length==0){
		$toast = $('<div></div>');
		$toast.addClass("mui-show-loading");
		$toast.addClass('loading-visible');
		$('body').append($toast);
		$toast.html(html);
		$toast.on("touchmove", function(e){e.stopPropagation();e.preventDefault();});
	}else{
		$toast.html(html);
		$toast.addClass("loading-visible");
	}
};

//隐藏加载框
commonUtils.hideLoading = function(callback) {
	var $mask=$(".mui-show-loading-mask");
	var $toast=$(".mui-show-loading");
	if($mask.length>0){
		$mask.addClass("mui-show-loading-mask-hidden");
	}
	if($toast.length>0){
		$toast.removeClass("loading-visible");
		callback && callback();
	}
  }
  //保存 base64为图片
commonUtils.baseImgFile =function(fileName, base64, quality, callback) {
	console.log("fileName="+fileName);
	var saveFile="_doc/"+fileName+".jpg";
	quality = quality || 100;
	callback = callback || function(i,bitmapIns){
		 commonUtils.showLoading("准备保存到相册",{maskBgColor:"transparent"});
		 commonUtils.saveToGallery(saveFile,bitmapIns);
	};
	var bitmap = new plus.nativeObj.Bitmap();
	// 从本地加载Bitmap图片
	bitmap.loadBase64Data(base64, function() {
		bitmap.save(saveFile, {
			overwrite: true,
			quality: quality
		}, function(i) {
			callback(i,bitmap);
		}, function(e) {
			commonUtils.hideLoading();
			mui.toast("保存图片失败",{ duration:'long', type:'div' });  
			console.log('保存图片失败：' + JSON.stringify(e));
		});
	  }, function(e) {
		   commonUtils.hideLoading();
		   mui.toast("加载图片失败",{ duration:'long', type:'div' }); 
		   console.log('加载图片失败：' + JSON.stringify(e));
	  });
  }
  //保存文件到相册（入参 文件路径）
 commonUtils.saveToGallery=function(fileName,bitmapIns){
	  plus.gallery.save(fileName, function () { 
		  commonUtils.hideLoading();
		  mui.toast("图片已保存到相册",{ duration:'long', type:'div' });  
		  if(bitmapIns){
			  bitmapIns.clear(); 
		  }
	  }, function () {  
		  commonUtils.hideLoading();
		  mui.toast("图片保存失败",{ duration:'long', type:'div' }); 
		  if(bitmapIns){
		   	bitmapIns.clear(); 
		  }
	  });  
  }
  
  //
  commonUtils.handleContentForVLinePic=function(content){
	  if(!content){
	  	return content;
	  }
	  content = content.replace(/\-/g,'<div class="inline-div">|</div>');
	  content = content.replace(/\:/g,'<div class="inline-div">:</div>');
	  content = content.replace(/\：/g,'<div class="inline-div">：</div>');
	  content = content.replace(/\,/g,'<div class="inline-div">,</div>');
	  content = content.replace(/\，/g,'<div class="inline-div">，</div>');
	  content = content.replace(/\!/g,'<div class="inline-div">!</div>');
	  content = content.replace(/\！/g,'<div class="inline-div">！</div>');
	  content = content.replace(/\?/g,'<div class="inline-div">?</div>');
	  content = content.replace(/\？/g,'<div class="inline-div">？</div>');
	  content = content.replace(/\./g,'<div class="inline-div">.</div>');
	  content = content.replace(/\。/g,'<div class="inline-div">。</div>');
	  return content;
  }

/****************************************************************/
function dateFormat(date,fmt) {
    var ret;
    var opt = {
        "Y+": date.getFullYear().toString(),        // 年
        "m+": (date.getMonth() + 1).toString(),     // 月
        "d+": date.getDate().toString(),            // 日
        "H+": date.getHours().toString(),           // 时
        "M+": date.getMinutes().toString(),         // 分
        "S+": date.getSeconds().toString(),          // 秒
		"s+": date.getMilliseconds().toString()      // 毫秒
        // 有其他格式化字符需求可以继续添加，必须转化成字符串
    };
    for (var k in opt) {
        ret = new RegExp("(" + k + ")").exec(fmt);
        if (ret) {
            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
        };
    };
    return fmt;
}

function fillDataToTpl(tpl,data){
	for(var name in data){
		var elem=$(tpl).find('[show-name="'+name+'"]');
		$(elem).html(data[name]||'');
		var attrEle=$(tpl).find('[fill-'+name.toLowerCase()+']');
		attrEle.attr('fill-'+name.toLowerCase(),data[name]||''); 
	}
}

function getFirstSentence(sentenceStr){
	if(sentenceStr){
		var tmpAttr=sentenceStr.split(/？|。|！/);
		if(tmpAttr.length>0){
			return tmpAttr[0]+"。";
		}
		return sentenceStr;
	}
	return null;
}

function replaceNextLine(dataEntry,name,checkCenter){
	if(!dataEntry[name]){
		return;
	}
	var contentList =  dataEntry[name].split("\n");
	var realContent='';
	if(checkCenter){
		dataEntry.useCenterStyle=true;
	}
	
	var lineCoutMap={};
	mui.each(contentList,function(index,value){
		//检测是否使用居中css--每行大于4个断句 或者有某个短句字数太长(15),那就可能不是古诗了
		if(checkCenter && value && dataEntry.useCenterStyle){
			var tmpAttr=value.split(/？|。|！|，/);
			if(tmpAttr.length>=4){
				var preLength=tmpAttr[0].length;
				for(var i=0;i<tmpAttr.length;i++){
					if(tmpAttr[i] && !tmpAttr[i].startsWith('（')){
						var currentLength=tmpAttr[i].length;
						if(currentLength!=preLength){
							dataEntry.useCenterStyle=false;
							break;
						}
					}
				}
			}
			if(dataEntry.useCenterStyle){
				for(var i=0;i<tmpAttr.length;i++){
					if(tmpAttr[i] && tmpAttr[i].indexOf("（") != -1 && tmpAttr[i].length>15){
						dataEntry.useCenterStyle=false;
					}
				}
			}
		}
		//检测结束
		realContent+=value+"<br/>";
	});
	dataEntry[name]=realContent;
}

function getDefPullUpRefreshOpt(opts){
	var pullRefresh={
		up: {
			height: 100, //可选.默认50.触发上拉加载拖动距离
			auto: true, //可选,默认false.自动上拉加载一次
			contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
			contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
		}
	}
	var mo=$.extend(true,{},pullRefresh,opts);
	return mo;
}

function muiAjaxGetJsonData(opts){
	if(opts.showLoading){
		commonUtils.showLoading("数据加载中..");
	}
	
	mui.ajax(opts.url, {
		data: opts.data,
		dataType: 'json', //服务器返回json格式数据
		type: 'get', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		success: function(data) {
			if(data && data.success){
				if(opts.callback){
					opts.callback(data);
				}
			}else{
				if(!data){
					console.info('没有返回数据')
				}else{
					var errMsg=data.msg||'服务器正忙！请稍后再试';
					mui.toast(errMsg,{ duration:'long', type:'div' });
				}
			}
			//
			commonUtils.hideLoading(function(){});
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(""+errorThrown+";"+type);
			//
			commonUtils.hideLoading(function(){});
		}
	});
}

function muiAjaxGetHtmlData(opts){
	if(opts.showLoading){
		commonUtils.showLoading("数据加载中..");
	}
	
	mui.ajax(opts.url, {
		data: opts.data,
		dataType: 'html', //服务器返回json格式数据
		type: 'get', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		success: function(data) {
			if(opts.callback){
				opts.callback(data);
			}
			//
			commonUtils.hideLoading(function(){});
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log("");
			//
			commonUtils.hideLoading(function(){});
		}
	});
}


/**************************************************/